package com.example.trabajofinal.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.example.trabajofinal.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapaItActivity extends android.support.v4.app.FragmentActivity {

	private GoogleMap theMap;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mapa_it_activity);
		
		if(theMap==null)
		{
		
			theMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

			if(theMap!=null)
			{
								
				theMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
			
				LatLng pos = new LatLng(-31.41615, -64.18895);
				
				theMap.addMarker(new MarkerOptions()
				.position(pos)
				.title("CapacitacionIt"));
				
	            CameraPosition camPos = new CameraPosition.Builder().target(pos).zoom(17).bearing(0).tilt(30).build();
	            theMap.animateCamera(CameraUpdateFactory.newCameraPosition(camPos));
			}
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {

		MenuInflater inflater = new MenuInflater(this);
		inflater.inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.cursos:
			Intent ic = new Intent(this, CursosActivity.class);
			startActivity(ic);
			finish();
			return true;

		case R.id.misCursos:
			Intent imc = new Intent(this, MisCursosActivity.class);
			startActivity(imc);
			finish();
			return true;			

		case R.id.mapsIT:
			Intent im = new Intent(this, MapaItActivity.class);
			startActivity(im);
			finish();
			return true;

		}

		return false;
	}

	@Override
	public boolean onPrepareOptionsMenu(Menu menu) {
		menu.getItem(0).setEnabled(true); //Cursos
		menu.getItem(1).setEnabled(true); // Mis Cursos
		menu.getItem(2).setEnabled(false); // Mapa
		return super.onPrepareOptionsMenu(menu);
	}
}
